home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 July
/
EnigmA AMIGA RUN 09 (1996)(G.R. Edizioni)(IT)[!][issue 1996-07 & 08][EARSAN CD VIII].iso
/
earcd
/
util3
/
cnvrtp34.lha
/
ConvertPICs.adpro
Wrap
Text File
|
1996-05-19
|
9KB
|
405 lines
/*
* $VER: ConvertPICs.adpro 3.4 (19.05.96)
*
* ©1995-96 Mirko Lukas
* Im Ziegenförth 5
* 38108 Braunschweig
* iceman@leslie.s-link.de
*
* Danke an:
* Detlef Peukert (poi@thunder.mcnet.de)
* Thomas Boerkel (tom@ai.inka.de)
*
* Script um ein komplettes Verzeichnis zu
* konvertieren. Es werden sowohl Format
* als auch Auflösung konvertiert.
*
* $HISTORY:
*
* 08.04.96 : 3.0 initial release
* 09.04.96 : 3.1 Fehler beim scalieren behoben
* 10.04.96 : 3.2 Optional können kleinere Bilder
* übersprungen werden
* 14.05.96 : 3.3 Fehler beim berechnen der zu
* scalierenden Größe behoben
* Genauere Einhaltung der Vorgaben
* 19.05.96 : 3.4 Fehler beim errechnen der Größe
* behoben
*
*/
/* Nur von ADpro aus zu starten */
if ~show('p', "ADPro") then exit 20
options results
address "ADPro"
tempdefaults = "T:TempADProDefaults"
prefsfile = "convert.prefs"
filelist = "T:TempFileList"
nl = '0A'x
/*********************************************************/
/* aktuelle ADPro-Einstellungen sichern */
call save_conf
/* Eigene Konfiguration laden */
call read_my_conf
version
ver = adpro_result
serial_number
num = adpro_result
/* Gag */
if (num = "") then num = "Raupkopie"
do while (cancel ~= 0)
okayn '"'def_ver'"',
'"Settings:' || nl || nl ||,
'Version: ' || ver || nl ||,
'Serialnumber: ' || num || nl || nl ||,
'max. x size: ' || def_x || nl ||,
'max. y size: ' || def_y || nl ||,
'Skip smaller pictures: ' || def_skip || nl ||,
'Saver module: ' || def_saver || nl ||,
'Save format: ' || def_image || nl ||,
'JPEG compression : ' || def_comp || nl ||,
'Delete old files: ' || def_del'"',
'"Use|Load|Edit|Save as...|Exit"'
if (rc ~= 0) then do
/* action */
if (rc = 1) then do
last_loaded_image
olddir = adpro_result
call get_dir olddir
workdir = result
if (workdir ~= 0) then do
/* Extension auswählen */
call set_ext
ext = result
/* Counter */
i_ges = 0
i_sca = 0
i_not = 0
i_sav = 0
/* Screenmode einstellen, wenn rendern auf ja */
if (def_image = "Rendered") then do
get_screen_mode '"Select a screenmode to render"' Amiga "XXX" def_x def_y 256
if (rc = 0) then
set_render_mode adpro_result
end
/* Fileliste erstellen */
address command "list " || workdir || " >" || filelist || " lformat %p%n files pat ~(#?.info)"
adpro_to_front
if (open(file, filelist, 'READ')) then do
do while ~eof(file)
line = readln(file)
if (line ~= "") then do
loader "UNIVERSAL" line
if (rc ~= 0) then leave
/* Größe */
xsize
width = adpro_result
ysize
height = adpro_result
/* zählen gesamt */
i_ges = i_ges + 1
/* scalieren */
if (width > def_x | height > def_y) then do
if ((width/height) * def_y <= def_x) then do
abs_scale width*def_y/height def_y
if (rc ~= 0) then leave
scale = 1
i_sca = i_sca + 1
end
else do
abs_scale def_x height*def_x/width
if (rc ~= 0) then leave
scale = 1
i_sca = i_sca + 1
end
end
else do
scale = 0
i_not = i_not + 1
end
if (def_skip = "No" | (def_skip = "Yes" & scale = 1)) then do
/* rendern */
if (def_image = "Rendered") then do
execute
close_render_screen
end
/* mitzählen */
i_sav = i_sav + 1
/* Löschen */
if (def_del = "Yes") then
address command "delete quiet " || line
/* Extension abschneiden */
if (left(right(line, 4), 1) = ".") then
line = delstr(line, lastpos('.', line), 4)
/* Neue Extension */
line = line || ext
/* Speichern */
if (def_saver = "JPEG") then do
saver def_saver line "RAW" quality def_comp
if (rc ~= 0) then leave
end
else do
if (def_image = "Rendered") then
saver def_saver line "IMAGE"
else
saver def_saver line "RAW"
if (rc ~= 0) then leave
end
address command "protect " || line || " -e"
end
end
end
dummy = close(file)
end
/* Meldung ausgeben */
okayn '"'def_ver'"',
'"Pictures found: ' || i_ges || nl || nl ||,
'Pictures procceded: ' || i_sca || nl ||,
'Pictures not scaled: ' || i_not || nl || nl ||,
'Pictures saved: ' || i_sav'"',
'"Continue"'
/* Fileliste löschen */
address command "delete quiet" filelist
end
end
/* settings laden */
if (rc = 2) then do
getfile '"Load ..." "" "'prefsfile'"'
if (rc ~= 0) then do
okay1 "No file specified."
end
else do
prefsfile = adpro_result
call read_my_conf
end
end
/* edit settings*/
if (rc = 3) then do
/* x size */
getnumber '"enter max. width"' def_x 3 16383
if (rc = 0) then def_x = adpro_result
/* y size */
getnumber '"enter max. height"' def_y def_x/4*3 16383
if (rc = 0) then def_y = adpro_result
/* Skip smaller pic's */
okayn '"'def_ver'"' '"Skip smaller pictures?"' '"Yes|No"'
if (rc = 0) then
def_skip = "No"
else
def_skip = "Yes"
/* Saver module */
getlist saver
if (rc = 0) then do
saverlist = adpro_result
listview '"Select a saver"' 10 sort items saverlist
if (rc >= 5) then
okay1 "An error occured, using old saver module."
else
parse var adpro_result '"'def_saver'"'
end
/* Dateiformat */
if (def_saver ~= "JPEG") then do
okayn '"'def_ver'"' '"Save rendered or raw data?"' '"Rendered|Raw"'
if (rc = 0) then
def_image = "Raw"
else
def_image = "Rendered"
end
else do
def_image = "Raw"
end
/* Compression */
if (def_saver = "JPEG") then do
getnumber '"Select compression quality for jpeg"' def_comp 1 1000
if (rc = 0) then def_comp = adpro_result
end
/* Alte Bilder löschen */
okayn '"'def_ver'"' '"Delete converted files?"' '"Yes|No"'
if (rc = 0) then
def_del = "No"
else
def_del = "Yes"
end
/* settings sichern */
if (rc = 4) then do
getfile '"Save as ..." "" "'prefsfile'"'
if (rc ~= 0) then do
okay1 "No file specified."
end
else do
prefsfile = adpro_result
if (open(prefs, prefsfile, 'WRITE')) then do
dummy = writeln(prefs, def_ver)
dummy = writeln(prefs, def_x)
dummy = writeln(prefs, def_y)
dummy = writeln(prefs, def_skip)
dummy = writeln(prefs, def_saver)
dummy = writeln(prefs, def_image)
dummy = writeln(prefs, def_del)
dummy = writeln(prefs, def_comp)
dummy = writeln(prefs, num)
dummy = close(prefs)
address command "protect "prefsfile" -e"
end
end
end
end
else do
cancel = 0
end
end
call restore_conf
exit 0
/**
** Ausgelagerte Funktionen
**/
/* Extension ermitteln */
set_ext:
extension = ""
if (def_saver = "ALIAS") then extension = ".als"
if (def_saver = "ANIM") then extension = ".anim"
if (def_saver = "BMP") then extension = ".bmp"
if (def_saver = "CDXL") then extension = ".cdxl"
if (def_saver = "GIF") then extension = ".gif"
if (def_saver = "ICON") then extension = ".info"
if (def_saver = "IFF") then extension = ".iff"
if (def_saver = "JPEG") then extension = ".jpg"
if (def_saver = "PCX") then extension = ".pcx"
if (def_saver = "PICT") then extension = ".pic"
if (def_saver = "POSTSCRIPT") then extension = ".eps"
if (def_saver = "QRT") then extension = ".qrt"
if (def_saver = "SGI") then extension = ".sgi"
if (def_saver = "TARGA") then extension = ".tga"
if (def_saver = "TIFF") then extension = ".tif"
if (def_saver = "X") then extension = ".x"
return extension
/* Eigene Konfiguration laden */
read_my_conf:
if (open(prefs, prefsfile, 'READ')) then do
def_ver = readln(prefs)
def_x = readln(prefs)
def_y = readln(prefs)
def_skip = readln(prefs)
def_saver = readln(prefs)
def_image = readln(prefs)
def_del = readln(prefs)
def_comp = readln(prefs)
dummy = close(prefs)
end
else do
def_ver = "ConvertPICs.adpro 3.4"
def_x = 800
def_y = 600
def_skip = "Yes"
def_saver = "JPEG"
def_image = "Raw"
def_del = "No"
def_comp = 32
end
if (compare(def_ver, "ConvertPICs.adpro 3.4") ~= 0) then do
okay1 '"Configfile unuseable, using default settings."'
def_ver = "ConvertPICs.adpro 3.4"
def_x = 800
def_y = 600
def_skip = "Yes"
def_saver = "JPEG"
def_image = "Raw"
def_del = "No"
def_comp = 32
end
return
/* Verzeichnis ermitteln */
get_dir:
parse arg defdir
if (rc ~= 0) then
defdir = "Ram:"
else
defdir = adpro_result
if (lastpos("/", defdir) ~= 0) then
defdir = delstr(defdir, lastpos("/", defdir))
else
if (lastpos(":", defdir) ~= 0) then
defdir = delstr(defdir, (lastpos(":", defdir)+1))
/* Auswahl */
getdir "'Select directory'" defdir
if (rc ~= 0) then do
okay1 "no directory specified."
return 0
end
else do
defdir = adpro_result
return defdir
end
/* Einstellungen sichern */
save_conf:
save_defaults tempdefaults
if (rc ~= 0) then do
adpro_to_front
okay1 "Error saving settings."
end
return
/* Einstellungen laden */
restore_conf:
if (exists(tempdefaults)) then do
load_defaults tempdefaults
if (rc ~= 0) then do
adpro_to_front
okay1 "Error restoring settings."
end
address command "delete quiet" tempdefaults
end
return